package com.vote.common.enums;

import org.apache.commons.lang3.StringUtils;

public enum VoteChoiceEnum {

    RATIO(0, "单选"),
    CHECKBOX(1, "多选");

    private Integer code;
    private String desc;

    VoteChoiceEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static VoteChoiceEnum getInstance(Integer code) {
        for (VoteChoiceEnum item : VoteChoiceEnum.values()) {
            if (code.equals(item.getCode())) {
                return item;
            }
        }
        return null;
    }

    public static VoteChoiceEnum getByDesc(String desc) {
        for (VoteChoiceEnum item : VoteChoiceEnum.values()) {
            if (StringUtils.equals(desc, item.getDesc())) {
                return item;
            }
        }
        return null;
    }

}
